package gsw.demo;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import gsw.demo.bean.Friend;
import gsw.eventbus.R;
import gsw.tool.eventbus.core.Hermes;
import gsw.tool.eventbus.eventbus.IEventBus;
import gsw.tool.eventbus.service.HermesService;

/**
 * 在子进程:f的Activity
 */
public class SecondActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        Hermes.getDefault().connect(this, HermesService.class);
    }

    public void post(View view) {
        IEventBus eventBus = Hermes.getDefault().getInstance(IEventBus.class);
        eventBus.post(new Friend("Tom", "12345678"));
        Toast.makeText(this, "发送消息成功，请返回上级页面查看", Toast.LENGTH_SHORT).show();
    }
}
